package stringBuffer;

import java.util.Scanner;

public class StringBufferDemo {
	public static void main(String[] args) {
		StringBuffer sb = new StringBuffer("java");
		System.out.println(sb);
		String s = sb.toString();
		System.out.println(s);
		// append()方法：追加字符串
		sb.append(" is good!");
		System.out.println(sb);
		// insert()方法：插入字符串
		sb.insert(2, ",");
		System.out.println(sb);
		
		Scanner input = new Scanner(System.in);
		System.out.print("请输入一串数字：");
		String str = input.next();
		StringBuffer info = new StringBuffer(str);
		for(int i = str.length() - 3; i > 0; i -= 3){
			info.insert(i, ",");
		}
		System.out.println(info);
	}

}
